/* 相关的接口信息 */
import request from './request.js'

/* 获取列表条数 */
export async function getSalaryListCounter() {
    let url = '/salary';
    return await request.get(url);
}

/* 添加薪资信息接口 */
export async function addSalary({ department, position, salary }) {
    let url = '/salary';
    await request.post(url, { department, position, salary });
}

/* 用户列表相关的接口 */
export async function getSalaryList({ page, limit }) {
    let url = '/salary';
    return await request.get(url, {
        params: {
            _page: page,
            _limit: limit
        }
    });
}

/* 用户删除接口 */
export async function deleteSalary(id) {
    let url = '/salary' + '/' + id;
    await request.delete(url);
}

/* 修改状态接口 */
export async function updateStatus(id, status) {
    let url = '/salary' + '/' + id;
    await request.patch(url, { status });
}

/* 修改薪资信息接口 */
export async function updateSalary(id, salary) {
    let url = '/salary' + '/' + id;
    if (salary) {
        await request.patch(url, { salary });
    }
}

/* 查询部门和职位 */
export async function findDepartAndPosition({ department, position }) {
    let url = '/salary';
    return await request.get(url, {
        params: {
            department, position
        }
    });
}

/* 查询字段相关信息 */
export async function findeSalaryMsg(value, keywords) {
    let url = '/salary';
    if (value == "department") {
        return await request.get(url, {
            params: {
                department_like: keywords
            }
        });
    }
    if (value == "position") {
        return await request.get(url, {
            params: {
                position_like: keywords
            }
        });
    }
}